﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Bling.DSL;
using Bling.WPF;
using Bling.Core;
using Bling.Angles;

namespace Bling.Tutorial {
  public class AngleTest : Canvas {
    public AngleTest() {
      CanvasBl Self = this;
      var thumbA = new ThumbBl(Self) {
        Size = 10, Background = Brushes.Red, CenterPosition = Double2Bl.Random * Self.Size, CanDrag = true,
        ZIndex = 1,
      };
      var thumbB = new ThumbBl(Self) {
        Size = 10,
        Background = Brushes.Blue,
        CenterPosition = Double2Bl.Random * Self.Size,
        CanDrag = true,
        ZIndex = 1,
      };
      var thumbAD = (thumbA - Self.CenterSize);
      var thumbBD = (thumbB - Self.CenterSize);
      var thumbAAngle = thumbAD.Angle;
      var thumbBAngle = thumbBD.Angle;

      var Delta = thumbAD.Normalize - thumbBAngle.SinCos;

      var thumbC = new ThumbBl(Self) {
        Size = 10,
        Background = Brushes.Red,
        CenterPosition = Self.CenterSize + thumbAAngle.SinCos * 100d,
        ZIndex = 0,
      };
      var thumbE = new ThumbBl(Self) {
        Size = 10,
        Background = Brushes.Purple,
        CenterPosition = Self.CenterSize + thumbAAngle.Transform(new Double2Bl(+100,0)),
        //CenterPosition = Self.CenterSize + (thumbAD.Normalize * (2d.PI() - thumbBAngle).SinCos).Normalize * 100d,
        ZIndex = 0,
      };

      new LineBl(Self) { Start = Self.CenterSize, End = thumbA };
      new LineBl(Self) { Start = Self.CenterSize, End = thumbB };

      new LabelBl(Self) {
        RightBottom = Self.Size,
        Content =
        (thumbA - Self.CenterSize).Angle.Normalize.ToStringBl(100d) + "\n" +
        (thumbB - Self.CenterSize).Angle.Normalize.ToStringBl(100d) + "\n" +

        ((thumbA - Self.CenterSize) * (2d.PI() - (thumbB - Self.CenterSize).Angle).SinCos).Angle.Normalize.ToStringBl(100d) + "\n" +
        (thumbA - Self.CenterSize).AngleBetween(thumbB - Self.CenterSize).Normalize.ToStringBl(100d) + "\n" +
        "",
      };

    }

  }
}
